package com.hsc.yalebao.tabIndex;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Editable;
import android.text.format.DateUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import android.widget.TextView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshGridView;
import com.hsc.yalebao.adapter.RoomListAdapter;
import com.hsc.yalebao.base.ActivityStack;
import com.hsc.yalebao.base.BaseActivity;
import com.hsc.yalebao.base.CustomApplication;
import com.hsc.yalebao.base.MainActivity;
import com.hsc.yalebao.http.AppConstants;
import com.hsc.yalebao.http.RequestNet;
import com.hsc.yalebao.model.BaseDataObject;
import com.hsc.yalebao.model.GetRoomRuleBaseBean;
import com.hsc.yalebao.model.GetRoomRuleBean;
import com.hsc.yalebao.model.RoomListBaseBean;
import com.hsc.yalebao.model.RoomListBean;
import com.hsc.yalebao.model.UserBaseBean;
import com.hsc.yalebao.model.UserBean;
import com.hsc.yalebao.tools.UiUtil;
import com.hsc.yalebao.weight.LogUtils;
import com.hsc.yalebao.weight.MyDialog1;
import com.hsc.yalebao.weight.MyDialogCancelAndOk;
import com.zhy.http.okhttp.callback.StringCallback;
import java.util.ArrayList;
import java.util.HashMap;
import okhttp3.Call;

public class RoomListActivity extends BaseActivity
  implements AdapterView.OnItemClickListener
{
  private String TAG = "RoomListActivity";
  private Context context;
  private EditText edit_pop_nickname;
  private View emptyView;
  private String guid = "";
  private PullToRefreshGridView gv_home;
  private RoomListAdapter homeListAdapter;
  private ImageView img_queding;
  private ImageView iv_title_right;
  private String lotteryid;
  private int memberId;
  private MyDialog1 myDialog1;
  private String nickName = "";
  private MyDialogCancelAndOk okandCanleDialog;
  View.OnClickListener onClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131099704:
      default:
        return;
      case 2131099699:
      }
      CustomApplication.app.finishActivity(RoomListActivity.this);
    }
  };
  private String parentid;
  private ArrayList<RoomListBaseBean> result;
  RoomListBaseBean roomListBaseBean;
  private PopupWindow setnicknamepop;
  private View view_title;
  private View viewsetnickname;

  private void ShowSetNickNamepopwindow()
  {
    (9 * (10 * (CustomApplication.app.displayMetrics.widthPixels / 10) / 10));
    this.setnicknamepop = new PopupWindow(this.viewsetnickname, -1, -1);
    this.setnicknamepop.setFocusable(true);
    ImageView localImageView = (ImageView)this.viewsetnickname.findViewById(2131100198);
    localImageView.bringToFront();
    localImageView.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        RoomListActivity.this.setnicknamepop.dismiss();
      }
    });
    this.setnicknamepop.setSoftInputMode(16);
    this.img_queding.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        RoomListActivity.this.closeWindowSoftInput(RoomListActivity.this.edit_pop_nickname);
        String str = RoomListActivity.this.edit_pop_nickname.getText().toString().trim();
        RoomListActivity.this.postData(str);
      }
    });
    this.setnicknamepop.setBackgroundDrawable(this.context.getResources().getDrawable(2130837534));
    this.setnicknamepop.setAnimationStyle(2131361795);
    this.setnicknamepop.showAtLocation(this.gv_home, 17, 0, 60);
    this.setnicknamepop.setOnDismissListener(new PopupWindow.OnDismissListener()
    {
      public void onDismiss()
      {
      }
    });
  }

  private void getIsEnterRoom()
  {
    HashMap localHashMap = new HashMap();
    if (this.roomListBaseBean == null)
    {
      LogUtils.e(this.TAG, "model==null:");
      return;
    }
    int i = this.roomListBaseBean.getId();
    localHashMap.put("memberid", this.memberId);
    localHashMap.put("roomid", i);
    localHashMap.put("client_Ip", CustomApplication.app.NetIP);
    LogUtils.i(this.TAG, "memberId:" + this.memberId);
    LogUtils.i(this.TAG, "roomId:" + i);
    showLoadingDialog();
    LogUtils.i(this.TAG, "getIsEnterRoom()-URL:" + AppConstants.URL_GET_ISENTERROOM);
    RequestNet.get(this.context, AppConstants.URL_GET_ISENTERROOM, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        RoomListActivity.this.dismissLoadingDialog();
        LogUtils.e(RoomListActivity.this.TAG, "获取失败,getParent2RoomListInfo-result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        RoomListActivity.this.dismissLoadingDialog();
        RoomListActivity.this.gv_home.onRefreshComplete();
        LogUtils.d(RoomListActivity.this.TAG, "result:" + paramAnonymousString);
        if (paramAnonymousString.isEmpty())
        {
          LogUtils.d(RoomListActivity.this.TAG, "s.isEmpty");
          RoomListActivity.this.gv_home.setEmptyView(RoomListActivity.this.emptyView);
          return;
        }
        Gson localGson = new Gson();
        try
        {
          localBaseDataObject = (BaseDataObject)localGson.fromJson(paramAnonymousString, BaseDataObject.class);
          if (localBaseDataObject == null)
          {
            LogUtils.e(RoomListActivity.this.TAG, "获取失败");
            return;
          }
        }
        catch (Exception localException)
        {
          BaseDataObject localBaseDataObject;
          while (true)
          {
            localException.printStackTrace();
            localBaseDataObject = null;
          }
          if (localBaseDataObject.getFlag() == -4)
          {
            RoomListActivity.activityStack.backToMain(MainActivity.class, RoomListActivity.this.context);
            return;
          }
          if (localBaseDataObject.getFlag() == 0)
          {
            RoomListActivity.this.ShowDialog1(localBaseDataObject.getMsg());
            return;
          }
          if (localBaseDataObject.getFlag() == -2)
          {
            RoomListActivity.this.showDownWireDialog();
            return;
          }
          if (localBaseDataObject.getFlag() == -3)
          {
            RoomListActivity.this.ShowFengjinDialog();
            return;
          }
          if ((RoomListActivity.this.nickName == null) || ("".equals(RoomListActivity.this.nickName)))
          {
            RoomListActivity.this.okandCanleDialog.show();
            RoomListActivity.this.okandCanleDialog.setMessage("请先设置你的昵称");
            RoomListActivity.this.okandCanleDialog.btn_cancle.setOnClickListener(new View.OnClickListener()
            {
              public void onClick(View paramAnonymous2View)
              {
                RoomListActivity.this.okandCanleDialog.dismiss();
              }
            });
            RoomListActivity.this.okandCanleDialog.btn_confirm.setOnClickListener(new View.OnClickListener()
            {
              public void onClick(View paramAnonymous2View)
              {
                RoomListActivity.this.ShowSetNickNamepopwindow();
                RoomListActivity.this.okandCanleDialog.dismiss();
              }
            });
            return;
          }
          RoomListActivity.this.intentToChatRoom();
        }
      }
    });
  }

  private void getParent2RoomListInfo()
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("parentID", this.parentid);
    localHashMap.put("lottery_id", this.lotteryid);
    showLoadingDialog();
    RequestNet.get(this.context, AppConstants.URL_GET_ROOMBYPARENTID, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        RoomListActivity.this.dismissLoadingDialog();
        LogUtils.e(RoomListActivity.this.TAG, "获取失败,getParent2RoomListInfo-result:" + paramAnonymousException);
        RoomListActivity.this.gv_home.onRefreshComplete();
      }

      public void onResponse(String paramAnonymousString)
      {
        RoomListActivity.this.dismissLoadingDialog();
        RoomListActivity.this.gv_home.onRefreshComplete();
        LogUtils.d(RoomListActivity.this.TAG, "result:" + paramAnonymousString);
        if (paramAnonymousString.isEmpty())
        {
          LogUtils.d(RoomListActivity.this.TAG, "s.isEmpty");
          RoomListActivity.this.gv_home.setEmptyView(RoomListActivity.this.emptyView);
        }
        RoomListBean localRoomListBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localRoomListBean = (RoomListBean)localGson.fromJson(paramAnonymousString, RoomListBean.class);
            if (localRoomListBean == null)
            {
              LogUtils.e(RoomListActivity.this.TAG, "获取失败");
              RoomListActivity.this.gv_home.setEmptyView(RoomListActivity.this.emptyView);
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localRoomListBean = null;
            }
            if (localRoomListBean.getFlag() == -4)
            {
              RoomListActivity.activityStack.backToMain(MainActivity.class, RoomListActivity.this.context);
              return;
            }
            if (localRoomListBean.getFlag() == -2)
            {
              RoomListActivity.this.showDownWireDialog();
              return;
            }
            if (localRoomListBean.getFlag() == -3)
            {
              RoomListActivity.this.ShowFengjinDialog();
              return;
            }
            if (localRoomListBean.getFlag() == 0)
            {
              UiUtil.showToast(RoomListActivity.this.context, localRoomListBean.getMsg());
              RoomListActivity.this.gv_home.setEmptyView(RoomListActivity.this.emptyView);
              return;
            }
          }
        }
        while (localRoomListBean.getFlag() != 1);
        RoomListActivity.this.result = localRoomListBean.getResult();
        if (RoomListActivity.this.result.size() == 0)
          RoomListActivity.this.gv_home.setEmptyView(RoomListActivity.this.emptyView);
        RoomListActivity.this.homeListAdapter.setData(RoomListActivity.this.result);
        RoomListActivity.this.homeListAdapter.notifyDataSetChanged();
      }
    });
  }

  private void init()
  {
    this.myDialog1 = new MyDialog1(this.context);
    this.okandCanleDialog = new MyDialogCancelAndOk(this.context);
    this.emptyView = LayoutInflater.from(this.context).inflate(2130903139, null);
    this.viewsetnickname = LayoutInflater.from(this.context).inflate(2130903166, null);
    this.edit_pop_nickname = ((EditText)this.viewsetnickname.findViewById(2131100217));
    this.img_queding = ((ImageView)this.viewsetnickname.findViewById(2131099841));
    this.gv_home = ((PullToRefreshGridView)findViewById(2131099940));
    this.gv_home.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
    this.gv_home.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2()
    {
      public void onPullDownToRefresh(PullToRefreshBase<GridView> paramAnonymousPullToRefreshBase)
      {
        LogUtils.d(RoomListActivity.this.TAG, "下拉");
        String str = DateUtils.formatDateTime(RoomListActivity.this.getApplicationContext(), System.currentTimeMillis(), 524305);
        paramAnonymousPullToRefreshBase.getLoadingLayoutProxy().setLastUpdatedLabel(str);
        RoomListActivity.this.getParent2RoomListInfo();
      }

      public void onPullUpToRefresh(PullToRefreshBase<GridView> paramAnonymousPullToRefreshBase)
      {
        LogUtils.d(RoomListActivity.this.TAG, "上拉");
      }
    });
    this.gv_home.setOnItemClickListener(this);
    this.result = new ArrayList();
    if (this.homeListAdapter == null)
    {
      this.homeListAdapter = new RoomListAdapter(this.context, this.result, "");
      this.gv_home.setAdapter(this.homeListAdapter);
    }
    getParent2RoomListInfo();
  }

  private void initUserData()
  {
    if (CustomApplication.app.userBaseBean != null)
    {
      this.nickName = CustomApplication.app.userBaseBean.getNick_name();
      this.memberId = CustomApplication.app.userBaseBean.getMemberid();
      this.guid = CustomApplication.app.userBaseBean.getGuid();
    }
  }

  private void intentToChatRoom()
  {
    if (this.roomListBaseBean == null)
    {
      LogUtils.e(this.TAG, "model==null:");
      return;
    }
    final int i = this.roomListBaseBean.getId();
    this.roomListBaseBean.getMin_betmoney();
    final String str = this.roomListBaseBean.allname;
    final int j = this.roomListBaseBean.getRoom_level();
    HashMap localHashMap = new HashMap();
    localHashMap.put("room_level", j);
    LogUtils.i(this.TAG, "getRoomRule()-room_level:" + j);
    RequestNet.get(this.context, AppConstants.URL_GET_GETROOMRULE, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        RoomListActivity.this.dismissLoadingDialog();
        LogUtils.e(RoomListActivity.this.TAG, "获取失败,getRoomRule-result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        RoomListActivity.this.dismissLoadingDialog();
        LogUtils.d(RoomListActivity.this.TAG, "result:" + paramAnonymousString);
        if (paramAnonymousString.isEmpty());
        GetRoomRuleBean localGetRoomRuleBean;
        do
        {
          return;
          Gson localGson = new Gson();
          try
          {
            localGetRoomRuleBean = (GetRoomRuleBean)localGson.fromJson(paramAnonymousString, GetRoomRuleBean.class);
            if (localGetRoomRuleBean == null)
            {
              LogUtils.e(RoomListActivity.this.TAG, "获取失败");
              return;
            }
          }
          catch (Exception localException)
          {
            while (true)
            {
              localException.printStackTrace();
              localGetRoomRuleBean = null;
            }
            if (localGetRoomRuleBean.getFlag() == -4)
            {
              RoomListActivity.activityStack.backToMain(MainActivity.class, RoomListActivity.this.context);
              return;
            }
            if (localGetRoomRuleBean.getFlag() == -2)
            {
              RoomListActivity.this.showDownWireDialog();
              return;
            }
            if (localGetRoomRuleBean.getFlag() == -3)
            {
              RoomListActivity.this.ShowFengjinDialog();
              return;
            }
            if (localGetRoomRuleBean.getFlag() == 0)
            {
              UiUtil.showToast(RoomListActivity.this.context, localGetRoomRuleBean.getMsg());
              return;
            }
          }
        }
        while (localGetRoomRuleBean.getFlag() != 1);
        GetRoomRuleBaseBean localGetRoomRuleBaseBean = localGetRoomRuleBean.getResult();
        if (localGetRoomRuleBaseBean != null)
        {
          Intent localIntent = new Intent(RoomListActivity.this, RoomPrimaryActivity.class);
          localIntent.putExtra("roomId", i);
          localIntent.putExtra("roomName", str);
          localIntent.putExtra("parentid", RoomListActivity.this.parentid);
          localIntent.putExtra("lotteryid", RoomListActivity.this.lotteryid);
          localIntent.putExtra("room_level", j);
          localIntent.putExtra("sumbet", localGetRoomRuleBaseBean.getSumbet());
          localIntent.putExtra("singlebet", localGetRoomRuleBaseBean.getSinglebet());
          localIntent.putExtra("minsinglebe", localGetRoomRuleBaseBean.getMinsinglebe());
          RoomListActivity.this.startActivity(localIntent);
          return;
        }
        LogUtils.e(RoomListActivity.this.TAG, "getRoomRule()-result != null");
      }
    });
  }

  private void postData(final String paramString)
  {
    if ("".equals(paramString))
    {
      ShowDialog1("昵称不能为空");
      return;
    }
    if (!UiUtil.isContainsChinese(paramString))
    {
      ShowDialog1("昵称需要包含中文");
      return;
    }
    if (paramString.length() > 7)
    {
      ShowDialog1("请输入7位以下包含中文的昵称");
      return;
    }
    HashMap localHashMap = new HashMap();
    localHashMap.put("nick_name", paramString);
    localHashMap.put("signature", "");
    localHashMap.put("guid", this.guid);
    RequestNet.post(this.context, AppConstants.URL_CHANGE_USER_INFO, localHashMap, new StringCallback()
    {
      public void onError(Call paramAnonymousCall, Exception paramAnonymousException)
      {
        LogUtils.e("返回失败", "result:" + paramAnonymousException);
      }

      public void onResponse(String paramAnonymousString)
      {
        LogUtils.d("返回成功", "result:" + paramAnonymousString);
        Gson localGson = new Gson();
        try
        {
          localUserBean = (UserBean)localGson.fromJson(paramAnonymousString, UserBean.class);
          if (localUserBean == null)
          {
            RoomListActivity.this.ShowDialog1("设置失败");
            return;
          }
        }
        catch (Exception localException)
        {
          UserBean localUserBean;
          while (true)
          {
            localException.printStackTrace();
            localUserBean = null;
          }
          if (localUserBean.getFlag() == -4)
          {
            RoomListActivity.activityStack.backToMain(MainActivity.class, RoomListActivity.this.context);
            return;
          }
          if (localUserBean.getFlag() == 1)
          {
            UserBaseBean localUserBaseBean = localUserBean.getResult();
            if ((localUserBaseBean != null) && (CustomApplication.app.userBaseBean != null))
              CustomApplication.app.userBaseBean.setNick_name(localUserBaseBean.getNick_name());
            if (CustomApplication.app.userBaseBean != null)
              CustomApplication.app.userBaseBean.setNick_name(paramString);
            RoomListActivity.this.closeWindowSoftInput(RoomListActivity.this.edit_pop_nickname);
            RoomListActivity.this.setnicknamepop.dismiss();
            RoomListActivity.this.intentToChatRoom();
            return;
          }
          if (localUserBean.getFlag() == -2)
          {
            RoomListActivity.this.showDownWireDialog();
            return;
          }
          UiUtil.showToast(RoomListActivity.this.context, localUserBean.getMsg());
        }
      }
    });
  }

  public void imageAction(RoomListBaseBean paramRoomListBaseBean)
  {
    this.roomListBaseBean = paramRoomListBaseBean;
    getIsEnterRoom();
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(2130903079);
    CustomApplication.app.addActivity(this);
    this.context = this;
    Bundle localBundle = getIntent().getExtras();
    if (localBundle != null)
    {
      if (localBundle.containsKey("parentid"))
        this.parentid = localBundle.getString("parentid");
      if (localBundle.containsKey("lotteryid"))
        this.lotteryid = localBundle.getString("lotteryid");
    }
    LogUtils.i(this.TAG, "parentid:" + this.parentid);
    LogUtils.i(this.TAG, "lotteryid:" + this.lotteryid);
    setTitle(8, 0, 2130837809, "房间列表", 0, 8, 8, 0, true);
    init();
  }

  protected void onDestroy()
  {
    super.onDestroy();
  }

  public void onItemClick(AdapterView<?> paramAdapterView, View paramView, int paramInt, long paramLong)
  {
    try
    {
      this.roomListBaseBean = ((RoomListBaseBean)this.result.get(paramInt));
      getIsEnterRoom();
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  protected void onPause()
  {
    super.onPause();
    closeWindowSoftInput(this.edit_pop_nickname);
  }

  protected void onResume()
  {
    super.onResume();
    initUserData();
  }

  @SuppressLint({"NewApi"})
  public void setTitle(int paramInt1, int paramInt2, int paramInt3, String paramString, int paramInt4, int paramInt5, int paramInt6, int paramInt7, boolean paramBoolean)
  {
    View localView = findViewById(2131099716);
    if (paramBoolean)
      localView.setVisibility(0);
    while (true)
    {
      ((TextView)localView.findViewById(2131099701)).setText(paramString);
      ((TextView)localView.findViewById(2131099700)).setVisibility(paramInt1);
      ImageView localImageView = (ImageView)localView.findViewById(2131099699);
      localImageView.setVisibility(paramInt2);
      localImageView.setOnClickListener(this.onClickListener);
      localImageView.setImageResource(paramInt3);
      TextView localTextView = (TextView)localView.findViewById(2131099702);
      localTextView.setVisibility(paramInt5);
      localTextView.setOnClickListener(this.onClickListener);
      this.iv_title_right = ((ImageView)localView.findViewById(2131099704));
      this.iv_title_right.setVisibility(paramInt6);
      this.iv_title_right.setOnClickListener(this.onClickListener);
      this.iv_title_right.setImageResource(paramInt7);
      return;
      localView.setVisibility(8);
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.hsc.yalebao.tabIndex.RoomListActivity
 * JD-Core Version:    0.6.2
 */